import * as Lodash from 'lodash';

export function apiTemplate(options: { BusinessName: any; moduleName: any; functionName: any; businessName: any; primaryKey: any }) {
  const { BusinessName, moduleName, functionName, businessName, primaryKey } = options;
  return `
    import request from '@/utils/request'
    // 查询${functionName}列表
    export function list${Lodash.upperFirst(BusinessName)}Api(query) {
      return request({
          url: '/${moduleName}/${businessName}/list',
          method: 'get',
          params: {
            orderByColumn:'${primaryKey}',
            isAsc:'descending',
            ...query
          }
      })
    }
    // 查询${functionName}详细
    export function get${Lodash.upperFirst(BusinessName)}Api(${primaryKey}) {
      return request({
          url: '/${moduleName}/${businessName}/' + ${primaryKey},
          method: 'get'
      })
    }
    
    // 新增${functionName}
    export function add${Lodash.upperFirst(BusinessName)}Api(data) {
      return request({
          url: '/${moduleName}/${businessName}',
          method: 'post',
          data: data
      })
    }

    // 修改${functionName}
    export function update${Lodash.upperFirst(BusinessName)}Api(data) {
      return request({
          url: '/${moduleName}/${businessName}',
          method: 'put',
          data: data
      })
    }

    // 删除${functionName}
    export function del${Lodash.upperFirst(BusinessName)}Api(${primaryKey}) {
      return request({
          url: '/${moduleName}/${businessName}/' + ${primaryKey},
          method: 'delete'
      })
    }

    `;
}
